package com.heba.view;

import android.app.Activity;
import android.app.ProgressDialog;

import com.heba.helper.ResourceHelper;


/**
 * Created by shenghao on 2015/5/14.
 * <p>
 *
 */
public class Loading {

    public ProgressDialog pd;
    public Activity context;

    public Loading(Activity c) {
        context = c;
    }

    /**
     */
    public void End() {
        if (pd != null && pd.isShowing())
            pd.dismiss();
    }

    public void Start(String msg) {
        if (pd == null) {
            pd = new ProgressDialog(context);
        }
        if (pd.isShowing()) {
            pd.setMessage(ResourceHelper.getResourceString(msg, context));
            return;
        }
        pd.setCancelable(true);
        pd.setCanceledOnTouchOutside(false);
        pd.setIndeterminate(true);
        pd.setMessage(ResourceHelper.getResourceString(msg, context));
        pd.show();
    }

    public void Start() {
        Start("loading");
    }
}